//
//  MyWalletHeader.m
//  FbeeAPP
//
//  Created by dev-m on 2018/3/19.
//  Copyright © 2018年 mohao. All rights reserved.
//

#import "MyWalletHeader.h"

@interface MyWalletHeader()<UIAlertViewDelegate>
{
    UIView *bgView;
    
    UILabel *addrL;
    
    UIButton *delBtn;
    
}

@end

@implementation MyWalletHeader

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, frame.size.width - 30, frame.size.height - 30)];
        bgView.layer.cornerRadius = 10;
        bgView.backgroundColor = UIColorFromRGB(0xECECEC);
        [self addSubview:bgView];
        
        UILabel *addrTitle = [UILabel makeLabel:^(TTLabelExtend *make) {
            make.addTextColor(FBEE_COLOR_THEME).addText(NSLocalizedString(@"uCenterWalletAddr", nil)).addFont([UIFont systemFontOfSize:14.0f]);
            make.setFrame(CGRectMake(20, 15, bgView.width - 40, 15));
            [bgView addSubview:make];
            
        }];
        
        addrL = [UILabel makeLabel:^(TTLabelExtend *make) {
            make.addTextColor(FBEE_COLOR_INFO).addText([UserInfoManager sharedManager].walletAddr).addFont([UIFont systemFontOfSize:14.0f]);
            make.setFrame(CGRectMake(20, addrTitle.bottom + 5, bgView.width - 40, 40));
            make.numberOfLines = 2;
            [bgView addSubview:make];
        }];
        
        delBtn = [UIButton makeButton:^(TTButtonExtend *make) {
            make.addFont([UIFont systemFontOfSize:14.0f]);
            make.addTitleColor(FBEE_COLOR_BLUE,UIControlStateNormal).addTitleColor(UIColorFromRGBA(0x000000, 0.5),UIControlStateHighlighted);
            make.addTitle(NSLocalizedString(@"mDelete", nil));
            make.setFrame(CGRectMake(0, 0, 60, 40));
            make.right = bgView.width;
            make.addTarget(self,@selector(delAction));
            [bgView addSubview:make];
        }];
    }
    
    return self;
}

-(void)delAction
{
    [[[UIAlertView alloc] initWithTitle:@"提示" message:@"您确认要删除当前钱包吗？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil] show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1 && self.onDel) {
        self.onDel();
    }
}

@end
